import { z } from 'zod'

export const AuthInfoSchema = z.object({
  canViewAbout: z.boolean(),
  canManageTodos: z.boolean(),
  canManageGroups: z.boolean(),
  canManageTags: z.boolean(),
})

export const LoginResponseSchema = z.object({
  token: z.string(),
})

export const UserInfoSchema = z.object({
  id: z.string(),
  name: z.string(),
})

export const AuthedUserSchema = z.intersection(
  UserInfoSchema,
  z.object({
    auth: AuthInfoSchema,
  })
)

export type AuthInfo = z.infer<typeof AuthInfoSchema>
export type UserInfo = z.infer<typeof UserInfoSchema>
export type LoginResponse = z.infer<typeof LoginResponseSchema>
export type AuthedUser = z.infer<typeof AuthedUserSchema>
